package Q2.service.impl;

import Q2.dao.StudentDao;
import Q2.pojo.Student;
import Q2.service.StudentService;
import lombok.AllArgsConstructor;
import lombok.NonNull;

/**
 * Student service default implementation
 *
 * @author chisheng
 */
@AllArgsConstructor
public class StudentServiceImpl implements StudentService {

    /**
     * Student dao
     */
    private final StudentDao studentDao;

    @Override
    public boolean addStudent(@NonNull Student student) {
        return studentDao.insertOne(student);
    }

    @Override
    public boolean removeStudent(int id) {
        return studentDao.deleteByPrimaryKey(id);
    }

    @Override
    public boolean updateStudent(@NonNull Student student) {
        return studentDao.updateByPrimaryKey(student);
    }

    @Override
    public Student query(@NonNull String id) {
        return studentDao.findByStudentNumber(id);
    }

}
